<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="fragment :: myhead(~{::title},~{})">
    <title >Ck Editor</title>
</head>
<body>
<fieldset class="layui-elem-field" style="margin-top: 30px;">
    <legend>文本编辑</legend>
    <div>
        <button id="btn_html" class="layui-btn layui-btn-small">获取Html</button>
        <button id="btn_text" class="layui-btn layui-btn-small">获取Text</button>
    </div>
    <div class="layui-field-box " id="editor" name="editor"></div>
</fieldset>
<script th:src="@{/ckeditor/ckeditor.js}"></script>
<script type="text/javascript">
    var editor = CKEDITOR.replace('editor');
    editor.setData('<h2 align="center">hello world</h2>');
    layui.use(['jquery'],function () {
        var $ = layui.jquery;
        $('#btn_html').on('click',function(){
            alert (CKEDITOR.instances.editor.getData());
        })
        $('#btn_text').on('click',function(){
            alert (CKEDITOR.instances.editor.document.getBody().getText());
        })
    })
</script>

</body>
</html>